package com.chenbei.controller.admin.erp;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenbei.common.domain.vo.ApiResponse;
import com.chenbei.common.domain.vo.Pagination;
import com.chenbei.common.util.ApiResponseUtil;
import com.chenbei.erp.domain.Customer;
import com.chenbei.erp.vo.req.CustomerReq;
import com.chenbei.erp.service.ICustomerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "WMS-客户管理")
@RestController("WMSCustomer")
@RequestMapping("/admin/erp/customer")
public class CustomerController {

    @Autowired
    private ICustomerService customerService;

    @Operation(summary = "新增客户")
    @PostMapping("add")
    private ApiResponse<Object> add(@Valid @RequestBody Customer customer) {
        customerService.add(customer);

        return ApiResponseUtil.success();
    }

    @Operation(summary = "更新客户")
    @PostMapping("update")
    private ApiResponse<Object> update(@Valid @RequestBody Customer customer) {
        customerService.update(customer);

        return ApiResponseUtil.success();
    }

    @Operation(summary = "客户列表")
    @GetMapping("pageList")
    public ApiResponse<Pagination<Customer>> pageList(CustomerReq CustomerReq) {
        Page<Customer> customerPage = customerService.pageList(CustomerReq);
        return ApiResponseUtil.success(customerPage);
    }
}
